<template>
	<view class="container">
		<view class="addrInfoView">
			<view class="addrItem" @click="addrItemTap(item, index)" v-for="(item, index) of itemList" :key='index'>
				<view class="left">
					<!-- <u-icon name="checkmark-circle" size='36rpx' color='#a8cd03'></u-icon> -->
				</view>
				<view class="contactInfo" style="margin-left: 20rpx;">
					<view class="name">
						<u-icon name="map" color='#d4a781' size='40rpx'></u-icon>
						<text style="font-weight: bold;font-size: 30rpx;margin-left: 16rpx;">{{item.name}}</text>
					</view>
					<text style="margin-top: 20rpx;margin-bottom: 14rpx;color: #666666;">
						详细地址：{{item.detailAddr}}
					</text>
					<view class="cantact" style="color: #666666;">
						<!-- <text>1.34千米</text> -->
						<text>{{item.contactName}}</text>
						<text style="margin-left: 40rpx;">{{item.contactPhone}}</text>
					</view>
				</view>
			</view>
		</view>
		
	</view>
</template>

<script>
	import {addrOfSelfPickup} from '@/api/addrOfSelfPickup.js'
	export default{
		data() {
			return {
				page: 1,
				size: 20,
				itemList: [],
				showEmpty: false,
				isLastPage: false,
				lesseeId: ''
			}
		},
		onLoad() {
			this.lesseeId = this.$Route.query.lesseeId
			this.getItemList()
		},
		onPullDownRefresh() {
			this.page = 1
			this.getItemList()
		},
		onReachBottom() {
			if(this.isLastPage) {
				return
			}
			this.getItemList()
		},
		methods:{
			getItemList(){
				addrOfSelfPickup.getAddrOfSelfPickupList({
					lessee: this.lesseeId
				}).then(res => {
					if(res.data.code == 10000){
						uni.stopPullDownRefresh();
						if (res.data.code == 10000) {
							if(this.page == 1){
								this.itemList = []
							}
							var list = res.data.data.list
							this.itemList = [...this.itemList, ...list]
							this.showEmpty = this.itemList.length<1
							if (res.data.data.next) {
								this.page += 1
							} else {
								this.isLastPage = true
							}
						}
					}
				})
			},
			//选择收货地址
			addrItemTap(item, index){
				var pages = getCurrentPages();
				var prevPage = pages[pages.length - 2]; //上一个页面
				prevPage.$vm.selectSelfPickupBack(encodeURIComponent(JSON.stringify(item)))
				uni.navigateBack();
			},
		}
	}
</script>

<style lang="scss" scoped>
	.container{
		background-color: #FFFFFF;
		height: 100%;
	}
	.addrInfoView{
		display: flex;
		flex-direction: column;
		.addrItem{
			display: flex;
			flex-direction: row;
			align-items: center;
			padding: 30rpx;
			border-bottom: 1px solid #EFEFEF;
			.left{
				flex-shrink: 0;
			}
			.contactInfo{
				display: flex;
				flex-direction: column;
				.name{
					display: flex;
					flex-direction: row;
				}
				.cantact{
					display: flex;
					flex-direction: row;
					align-items: center;
				}
			}
			.right{
				flex-shrink: 0;
			}
		}
	}
	.footer{
		width: 100%;
		display: flex;
		flex-direction: column;
		align-items: center;
		position: fixed;
		bottom: 0;
		height: 140rpx;
	}
</style>
